package ro.fortech.workshop_demo.activities;

import android.os.Bundle;
import android.webkit.WebView;
import ro.fortech.workshop_demo.R;
import ro.fortech.workshop_demo.business.SeasonsManager;
import ro.fortech.workshop_demo.data.GrandPrix;

/**
 * User: florinv
 * Date: 4/18/13
 * Time: 3:03 PM
 */
public class GrandPrixDetails extends Main {
    /**
     * Called when the activity is first created.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.grand_prix_details);
        // Get the index of the clicked list row
        int index = getIntent().getIntExtra(Seasons.EXTRA_ROW_INDEX, -1);
        // Get the grand prix corresponding to the clicked row index
        GrandPrix grandPrix = SeasonsManager.getInstance().getGrandPrixList().get(index);
        // Inflate thw web view in which we'll load the grand prix details
        WebView webView = (WebView) findViewById(R.id.grand_prix_details_web_view);
        // Enable support for JavaScript
        webView.getSettings().setJavaScriptEnabled(true);
        // Load the url into the web view
        webView.loadUrl(grandPrix.getDetailsUrl());
    }
}
